<?php

/**
 * Form Radio Element class
 *
 * @author Mathieu Pheulpin - sokaru91@gmail.com
 *
 */
class Mac_Form_Element_Radio extends Mac_Form_Element_Abstract
{
    protected $realValue;

    public function __construct ($id, $groupName, $value, $label = null)
    {
        parent::__construct($groupName);
        $this->id = $id;
        $this->realValue = (string)$value;
        $this->label = $label;
    }

    public function __toString ()
    {
        return '<input
            type="radio"
            id="'.$this->id.'"
            name="'.$this->name.'"
            value="'.$this->realValue.'"
            '.(($this->realValue === $this->value) ? 'checked="checked"' : '').'
            '.((count($this->class) > 0) ? 'class="'.implode(' ', $this->class).'"' : '').'
            '.$this->printOptions().'
        />';
    }

}